<template>
  <!-- 收货启动,记录卸货人 -->
		<div class="ywshouhuo_xhr">
			<van-nav-bar :fixed="true" class="navBar" title="入库收货" left-arrow @click-left="$router.go(-1)"></van-nav-bar>
				<div class="goodsFromTwo" style="padding-top:0px;padding-bottom: 0px;">
					<div class="goodsInputWarp">
							<div class="goodsInputLabel">
								<div class="goodsInputBorder"></div>
								<div class="skuName">收货单：</div>
							</div>
							<van-field
								 class="skuInput"
								 clearable
								 v-model="editForm.bill"
								 placeholder="请填写收货单"
								 @keyup="onEnter($event,do_inputspbar)"

							 />

							<div class="searchBtn">
								<button :disabled="isdisabled"  @click.stop="doQuery('%')" >
									<van-icon name="ellipsis" color="#1989fa"  />
								</button>
							</div>
					</div>


					<div class="goodsInputWarp">
							<div class="goodsInputLabel">
								<div class="goodsInputBorder"></div>
								<div class="skuName">商品条码：</div>
							</div>
							<van-field
								 class="skuInput"
								 clearable
								 v-model="editForm.itemid"
								 placeholder="请填写商品条码"
								 @keyup="onEnter($event,do_inputspbarItem)"
								 @focus="(event)=>{event.target.select()}"
								 ref="inputField"
							 />
							<div class="searchBtn">
									<button :disabled="isdisabled"  @click.stop="_getSKUdetails('DJ')" >
										<van-icon name="ellipsis" color="#1989fa"  />
									</button>
							 </div>
					</div>

					<div class="tishiMessage" style="margin-bottom: 0px;">
					[{{editForm.whstype == '直通库'?'黄签':'白签'}}] {{editForm.whsxs}} {{editForm.vendor}} {{editForm.vendor>''?'-':''}} {{editForm.venname}}
					</div>



					<div class="tishiMessage" style="margin-bottom: 0px;">
						{{danjuhuizong.mx1}}
					</div>




					<van-row class="goodsNameWarp" style="margin-bottom: 0px;" >
							<span class="label">商品名称：</span>
							<span class="value"> {{editForm.subsname}}</span>
					</van-row>

					<div class="tishiMessage" style="margin-bottom: 0px;">
						{{danjuhuizong.mx2}} 箱装： {{editForm.unit}}
					</div>



					<div class="rowInput">
							<div class="rowInput_left">
									<div class="rowInputLabel">
										<div class="">箱数：</div>
									</div>

									<input
										 type="text"
                     @focus="refActive = 'pack'"
										 class="input_tow"
										 clearable
										 v-model="editForm.pack"
										 placeholder="箱数"
										 @keyup="onEnter($event,selectInputRef)"
										 ref="inputPack"
									 />
							</div>

							<div class="rowInput_right">
									<div class="rowInputLabel">
										<div class="">散数：</div>
									</div>

									<input
										 type="text"
                     @focus="refActive = 'qty'"
										 class="input_tow"
										 clearable
										 v-model="editForm.qty"
										 placeholder="散数"
										 @keyup="onEnter($event,selectInputRef)"
										 ref="inputQty"
									 />
							</div>
					</div>






					<div class="goodsInputWarp">
							<div class="goodsInputLabel">
								<div class="goodsInputBorder"></div>
								<div class="skuName">生产日期：</div>
							</div>
							 <!-- type="date" -->
							<input
                 @focus="refActive = 'pdata'"
								 ref="inputPdata"
								 @keyup="onEnter($event,selectInputRef)"
								 @input="validateDate"
								 placeholder="YYYYMMDD"
								 type="text"
								 class="skuInputdate"
								 clearable
								 v-model="editForm.p_date"
							 />
					</div>
					<div class="errorMessage">
            {{errorMessage}}
          </div>





					<div class="goodsInputWarp">
							<div class="goodsInputLabel">
								<div class="goodsInputBorder"></div>
								<div class="skuName">入库标签：</div>
							</div>

							<van-field
								 ref="inputSherno"
								 class="skuInput"
								 clearable
								 v-model="editForm.shserno_s"
								 placeholder="请填写入库标签"
								 @keyup="onEnter($event,do_inputspbarSherno)"
							 />
					</div>
				</div>

				<div class="submitBtn">
					<van-button type="info" :disabled="isdisabled" @click="selectShouHuoListBtn()">收货列表</van-button>
					<van-button type="info" :disabled="isdisabled" @click="saveZhengDanBtn()">整单结单</van-button>
					<van-button type="info" :disabled="isdisabled" @click="saveXiaoYanBtn()">确认收货</van-button>
				</div>

				<!-- 选择收货单 -->
				<van-overlay :show="selectBillsVisible" :lock-scroll="false">
				  <div class="shipandanWrapper" @click.stop>
							<van-sticky>
							    <van-nav-bar
											class="navBar"
							        title="选择收货单"
							        left-arrow
							        @click-left="selectBillsVisible = false;isdisabled = false;"
							        >
							    </van-nav-bar>
							</van-sticky>

							<div class="shipandanCon">
									<div  v-for="(row,i) in yujianTable" :key="i" class="danjuRow" @click="selectYujiandan(row)">
										<p><span>单号：</span>{{row.bill}}</p>
										<!-- SH 收货 DBSH 调拨收货 PSFC 配送返仓 -->
										<p><span>收货类型：</span>{{filterBillType(row.billtype)}}</p>

										<div class="venRow">
											<div class="venLabel">供应商：</div>
											<div class="venValue">{{row.vendor+'-'+row.venname}}</div>
										</div>



										<p><span>仓别：</span>{{row.whstype}}</p>
										<p><span>门店号：</span>{{row.storeid}}</p>
										<!-- 0 录入 1 审核 -->
										<p><span>状态：</span>{{row.status==0?'录入':'审核'}}</p>
									</div>
							</div>

				  </div>
				</van-overlay>


				<van-overlay :show="selectSkuVisible"  :lock-scroll="false">
					<div class="shipandanWrapper" @click.stop>
						<van-sticky>
							<van-nav-bar
							class="navBar"
							title="选择商品"
							left-arrow
							@click-left="selectSkuVisible = false;isdisabled = false;"/>
						</van-sticky>

						<div class="shipandanCon" @click.stop>
								<div  v-for="(row,i) in skuData" :key="i" class="danjuRow" @click="selectSku(row)">
									<!-- <p><span>商品名称：</span>{{row.subsname}}</p> -->

									<div class="venRow">
										<div class="venLabel">商品名称：</div>
										<div class="venValue">{{row.subsname}}</div>
									</div>

									<p><span>商品编码：</span>{{row.itemid}}</p>
									<p><span>子码：</span>{{row.subid}}</p>
									<p><span style="width: 100px;">应收数量：</span>{{row.totqty}} <span style="width: 100px;">&nbsp;&nbsp;应收箱数：</span>{{row.pack}}</p>
									<p><span style="width: 100px;">已收数量：</span>{{row.ystotqty}} <span style="width: 100px;">&nbsp;&nbsp;已收箱数：</span>{{row.yspack}}</p>
									<p><span>箱装：</span>{{row.unit}}</p>
									<p><span>单位：</span>{{row.kcuom}}</p>
								</div>
						</div>
					</div>

				</van-overlay>






				<van-overlay :show="selectShuoHuoDanVisible" :lock-scroll="false">
					<div class="shipandanWrapper">
							<van-sticky>
								<van-nav-bar class="navBar" title="收货单列表" left-arrow @click-left="selectShuoHuoDanVisible = false"></van-nav-bar>
							</van-sticky>
							<div class="shipandanCon" @click.stop>
									<div  v-for="(row,i) in shouHuoData" :key="i" class="danjuRow" >
										<p><span>商品名称：</span>{{row.subsname}}</p>
										<p><span>商品编码：</span>{{row.itemid}}</p>
										<p><span>入库标签：</span>{{row.shserno_s}}</p>
										<p><span>生产日期：</span>{{row.p_date}}</p>
										<p><span>箱装：</span>{{row.unit}}</p>
										<p><span>箱数：</span>{{row.pack}}</p>
										<p><span>散数：</span>{{row.qty}}</p>
										<p><span>总数量：</span>{{row.totqty}}</p>
									</div>
							</div>
					</div>

				</van-overlay>


		</div>

</template>

<script>
import { mapActions } from "vuex";
export default {
  name: 'ywshouhuo_yhsh',
  data () {
    return {
			editForm:{
				bill:'',
				billtype:'',
				subsname:'',
				itemid:'',
				posin:'',
				storeid:'', //门店ID
				venname:'',  //供应商名称
				vendor:'',   //供应商
				subsname:'', //商品名称
				totqty:'',  //应收数量
				ystotqty:'', //已收数量
				unit:'',  //箱装
				kcuom:'', //单位
				pack:'',  //箱数
				qty:'',
				shserno_s:'',
				whstype:'',
			},
			selectBillsVisible:false,
			isdisabled:false,
			yujianTable:[],
			timeoutId: null,
			danjuhuizong:{},
			skuData:{},
			selectSkuVisible:false,
			shouHuoData:[],
			selectShuoHuoDanVisible:false,
		  formattedDate: '',
			formattedDate: '',
			errorMessage: '',
			refActive:'pack',
    }
  },
  methods: {
		 ...mapActions(["showLoading", "hideLoading"]),
		validateDate(){
				const currentYear = new Date().getFullYear();
				this.errorMessage = '';
				this.formattedDate = '';

				if (this.editForm.p_date.length === 8) {
					 const year = this.editForm.p_date.slice(0, 4);
					 const month = this.editForm.p_date.slice(4, 6);
					 const day = this.editForm.p_date.slice(6, 8);

					 // 检查年份是否在有效范围内
					 if (year < 2000) {
						 this.errorMessage = '年份必须在2000年或之后。';
						 return;
					 }

					 // 验证月份
					 if (month < 1 || month > 12) {
						 this.errorMessage = '月份必须在1-12之间。';
						 return;
					 }

					 // 验证天数
					 if (!this.isValidDay(year, month, day)) {
						 this.errorMessage = '日期不正确，天数必须在1-31之间。';
						 return;
					 }

				 // 格式化日期
				 this.editForm.p_date = `${year}-${month}-${day}`;
				} else if (this.editForm.p_date.length === 4) {
				 const month = this.editForm.p_date.slice(0, 2);
				 const day = this.editForm.p_date.slice(2, 4);
				 const year = currentYear.toString();

				 // 检查年份是否在有效范围内
				 if (year < 2000) {
					 this.errorMessage = '年份必须在2000年或之后。';
					 return;
				 }

				 // 验证月份
				 if (month < 1 || month > 12) {
					 this.errorMessage = '月份必须在1-12之间。';
					 return;
				 }

				 // 验证天数
				 if (!this.isValidDay(year, month, day)) {
					 this.errorMessage = '日期不正确，天数必须在1-31之间。';
					 return;
				 }

				 // 格式化日期
				 this.editForm.p_date = `${year}-${month}-${day}`;
			 } else if (this.editForm.p_date.length > 0) {
				 this.errorMessage = '只能按照 YYYYMMDD 或 MMDD 格式输入。';
		  }

		},
		isValidDay(year, month, day) {
			const date = new Date(year, month - 1, day);
			return date.getFullYear() == year && date.getMonth() == month - 1 && date.getDate() == day;
		},
		selectInputRef(){
			console.log("回车")
			if(this.refActive == 'pack'){
				this.refActive = 'qty'
				this.$refs.inputQty.focus();
			}else if(this.refActive == 'qty'){
				this.refActive = 'pdata'
				this.$refs.inputPdata.focus();
			}else if(this.refActive == 'pdata'){
				this.$refs.inputSherno.focus();
			}
		},
		do_inputspbarSherno(pmtxt){
				console.log(pmtxt)  //扫描枪获取的参数
				this.editForm.shserno_s = pmtxt
				this.saveShouHuoBtn()
		},
    saveXiaoYanBtn(){
      console.log("传入的值")
			 console.log(this.editForm)
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
			 	'method':'dgate',
			 	'pname':'f_wmsa_y_shouhuo',
			 	'i':this.FNULLE([
			 	'opmode','Y_YHSH_jy_bzq',
        'kqid', _self.ryuser.kqid,
        'czyid',_self.ryuser.operatorid,
			 	'itemid',this.editForm.itemid,
			 	'subid',this.editForm.subid,
			 	'p_date',this.editForm.p_date,
			 	])
			 	}, '效验收货',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
			 	if(ret_iserr){ //传入的true参数,理论上不会有此回调了
			 		_self.$toast.fail('查询失败')
			 		_self.$store.commit('hideLoading');
			 	}else{
			 		var rtn_json_obj = null;
			 		_self.$store.commit('hideLoading');
			 		if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
			 		}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
			 		}
			 		console.log("得到效验收货")
			 		console.log(rtn_json_obj[0])
          if(rtn_json_obj[0].ret_ret == '0'){
            _self.saveShouHuoBtn()
          }else if(rtn_json_obj[0].ret_ret == '-1'){
            _self.$dialog.confirm({
              title: '提示',
              message: rtn_json_obj[0].ret_mess + '，是否继续？',
            }).then(() => {
              // 用户点击确认，继续执行
              _self.saveShouHuoBtn()
            }).catch(() => {
              // 用户点击取消，不做任何操作
            });
          }
			 	}
			 });
    },
    // 确认收货
		saveShouHuoBtn(){
			 console.log("传入的值")
			 console.log(this.editForm)
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
			 	'method':'dgate',
			 	'pname':'f_wmsa_shouhuo',
			 	'i':this.FNULLE([
			 	'opmode','YHSH_qritemid',
			 	'bill',this.editForm.bill,
			 	'itemid',this.editForm.itemid,
			 	'subid',this.editForm.subid,
			 	'p_date',this.editForm.p_date,
			 	'pack',this.editForm.pack,
			 	'qty',this.editForm.qty,
			 	'unit',this.editForm.unit,
			 	'shserno_s',this.editForm.shserno_s,
			 	'czyid',this.ryuser.operatorid,
			 	])
			 	}, '确认收货',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
			 	if(ret_iserr){ //传入的true参数,理论上不会有此回调了
			 		_self.$toast.fail('查询失败')
			 		_self.$store.commit('hideLoading');
			 	}else{
			 		var rtn_json_obj = null;
			 		_self.$store.commit('hideLoading');
			 		if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
			 		}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
			 		}
			 		console.log("得到确认收货")
			 		console.log(rtn_json_obj[0])
					if(rtn_json_obj[0].ret_ret == '-1'){
						_self.$toast(rtn_json_obj[0].ret_mess)
					}else{
						_self.$toast(rtn_json_obj[0].ret_mess)
							console.log("在这情空")
							_self.editForm.subsname = ''
							_self.editForm.totqty = ''
							_self.editForm.ystotqty = ''
							_self.editForm.unit = ''
							_self.editForm.kcuom = ''
							_self.editForm.pack = ''
							_self.editForm.qty = ''
							_self.editForm.p_date = ''
							_self.editForm.shserno_s = ''
							_self.editForm.itemid = ''
							_self.danjuhuizong = {
								num_bq:'',
								num_tp:'',
								yings:'',
								yis:'',
								pznum:'',
								mx1:'',
								mx2:'',
							}
							_self.$refs.inputField.focus();
					}
			 	}
			 });
		 },
		 selectShouHuoListBtn(){
				console.log(this.editForm.bill)
				if(this.editForm.bill == ''){
					return	this.$toast.fail('请选择收货单')
				}
				var _self = this;
				var ldemodata = [{retval:0, errmsg:'返回数据集'},]
				this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_shouhuo',
					'i':this.FNULLE([
					'opmode','YHSH_ysitemid',
					'bill',this.editForm.bill,
					])
					}, '收货列表',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
					if(ret_iserr){ //传入的true参数,理论上不会有此回调了
						_self.$toast.fail('查询失败')
						_self.$store.commit('hideLoading');
					}else{
						var rtn_json_obj = null;
						_self.$store.commit('hideLoading');
						if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
						}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
						}
						_self.shouHuoData = rtn_json_obj
						console.log("得到收货列表")
						console.log(_self.shouHuoData)
						if(_self.shouHuoData.length > 0){
							_self.selectShuoHuoDanVisible = true
						}else{
							_self.$toast.fail('暂无收货列表详情')
						}
					}
				});
		 },
		 selectSku(row){
			 console.log(row)
			 this.editForm.itemid = row.itemid
			 this.editForm.subsname = row.subsname
			 this.editForm.subid = row.subid
			 this.editForm.totqty = row.totqty
			 this.editForm.ystotqty = row.ystotqty
			 this.editForm.unit = row.unit
			 this.editForm.kcuom = row.kcuom
			 this.searchDanjuHuiZong()
			 this.selectSkuVisible = false
		 },
		 searchItemIdBtn(){
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_shouhuo',
				'i':this.FNULLE([
					'opmode','YHSH_qryitemid',
					'bill',this.editForm.bill,
					'billtype',this.editForm.billtype,
					'posin',this.editForm.posin,
					'storeid',this.editForm.storeid,
					'itemid',this.editForm.itemid,
				])
				},'根据商品条码查询商品信息',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					_self.skuData = rtn_json_obj
					console.log("根据商品条码查询商品信息")
					console.log(_self.skuData)
					if(_self.skuData.length > 1){
						_self.selectSkuVisible = true
					}else if(_self.skuData.length == 1){
						_self.editForm.itemid 	= _self.skuData[0].itemid
						_self.editForm.subsname = _self.skuData[0].subsname
						_self.editForm.subid 		= _self.skuData[0].subid
						_self.editForm.totqty 	= _self.skuData[0].totqty
						_self.editForm.ystotqty = _self.skuData[0].ystotqty
						_self.editForm.unit 		= _self.skuData[0].unit
						_self.editForm.kcuom 		= _self.skuData[0].kcuom
						// _self.editForm.pack 		= _self.skuData[0].pack
						_self.editForm.pack 		= ''
						_self.searchDanjuHuiZong();
						_self.$toast('查询到一条商品数据')
					}else{
						_self.$toast.fail('暂无商品详情')
					}
				}
			 });
		 },
		 filterBillType(type){
			 // SH 收货 DBSH 调拨收货 PSFC 配送返仓
			 if(type =='SH'){
				 return '收货'
			 }else if(type == 'DBSH'){
				  return '调拨收货'
			 }else if(type == 'PSFC'){
				  return '配送返仓'
			 }
		 },
		 searchYujiandan(){
			 this.selectBillsVisible = true
		 },
		 selectYujiandan(row){
			 this.editForm.bill = row.bill
			 this.editForm.posin = row.posin
			 this.editForm.storeid = row.storeid
			 this.editForm.venname = row.venname
			 this.editForm.vendor = row.vendor
			 this.editForm.whstype = row.whstype
			 this.editForm.billtype = row.billtype
			 this.editForm.whsxs = row.whsxs
			 this.selectBillsVisible = false
			 this.isdisabled = false
			 this.searchDanjuHuiZong()
			 // 清空商品
			 this.editForm.itemid = ''
			 this.editForm.subsname = ''
			 this.editForm.unit = ''
			 this.editForm.pack = ''
			 this.editForm.qty = ''

		 },
		searchDanjuHuiZong(){
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
			 	'method':'dgate',
			 	'pname':'f_wmsa_shouhuo',
			 	'i':this.FNULLE([
					'opmode','YHSH_qryhzbill',
					'bill',this.editForm.bill,
					'billtype',this.editForm.billtype,
					'itemid',this.editForm.itemid,
			 	])
			 	}, '查单据汇总',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
			 	if(ret_iserr){ //传入的true参数,理论上不会有此回调了
			 		_self.$toast.fail('查询失败')
			 		_self.$store.commit('hideLoading');
			 	}else{
			 		var rtn_json_obj = null;
			 		_self.$store.commit('hideLoading');
			 		if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
			 		}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
			 		}
			 		_self.danjuhuizong = rtn_json_obj[0]
			 		console.log("得到数据单据汇总")
			 		console.log(_self.danjuhuizong)
					_self.$refs.inputPack.focus();
			 	}
			 });
		},
		do_inputspbarItem(pmtxt){
				console.log(pmtxt)  //扫描枪获取的参数
				this.editForm.itemid = pmtxt
				// 先转换为商品条码在调用
				this._getSKUdetails('SM')
				// this.zhuanSKUid('SM')
		},
		_getSKUdetails(type){
			console.log(type)
			if(type == 'SM'){
				// 如果用户扫码调用转商品的数据然后调用查询商品详情
				this.zhuanSKUid()
			}else if(type =='DJ'){
				// 如果是用户点击直接调用扫码查全部
				this.searchAllItemIdBtn()
			}
		},
		zhuanSKUid(){
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_y_chaxun',
				'i':this.FNULLE([
				'opmode','qry_item005',
					'czyid',this.ryuser.operatorid,
					'kqid', this.ryuser.kqid,
					'cwno',this.editForm.cwno,
					'itemid',this.editForm.itemid,
				])
				}, '转化商品条码',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					console.log("得到转化商品条码")
					console.log(rtn_json_obj)
					if(rtn_json_obj.length > 0){
						_self.editForm.itemid =  rtn_json_obj[0].itemid
						_self.searchItemIdBtn()
					}else{
							_self.$toast.fail('查询商品失败请核实')
					}
				}
			});
		},
		// 扫码的时候还继续查询商品点击的时候要查全部展示出来
		searchAllItemIdBtn(){
					 var _self = this;
					 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
					 this.MYPOST({
						'method':'dgate',
						'pname':'f_wmsa_shouhuo',
						'i':this.FNULLE([
							'opmode','YHSH_qryitemid',
							'bill',this.editForm.bill,
							'billtype',this.editForm.billtype,
							'posin',this.editForm.posin,
							'storeid',this.editForm.storeid,
							'itemid','%',
						])
						},'根据商品条码查询商品信息',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
						if(ret_iserr){ //传入的true参数,理论上不会有此回调了
							_self.$toast.fail('查询失败')
							_self.$store.commit('hideLoading');
						}else{
							var rtn_json_obj = null;
							_self.$store.commit('hideLoading');
							if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
							}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
							}
							_self.skuData = rtn_json_obj
							console.log("根据商品条码查询商品信息")
							console.log(_self.skuData)
							if(_self.skuData.length > 0 ){
								_self.selectSkuVisible = true
							}else{
								_self.$toast.fail('暂无商品详情')
							}
						}
					 });
		},
		doSkuCodeQuery(){
			console.log(this.editForm.bill)
			console.log(this.editForm.posin)
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_shouhuo',
				'i':this.FNULLE([
				'opmode','YHSH_qryitemid',
				'bill',this.editForm.bill,
				'posin',this.editForm.posin,
				'storeid',this.editForm.storeid,
				'itemid',this.editForm.itemid,,
				])
				}, '商品条码',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					_self.skuData = rtn_json_obj
					console.log("得到商品条码")
					console.log(_self.skuData)
					if(_self.skuData.length > 0){
						_self.selectSkuVisible = true
					}else{
						_self.$toast.fail('暂无商品详情')
					}
				}
			});
		},
		do_inputspbar(pmtxt){
			console.log(pmtxt)  //扫描枪获取的参数
			this.editForm.bill = pmtxt
			this.doQuery('1')
		},
		doQuery(val){
			console.log(val)
			if(val == '%'){
				this.editForm.bill = '%'
			}

			this.isdisabled = true
			// 原型阶段用到的字段,及字段的demo值!!!
			var _self = this;
			var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			this.MYPOST({
				'method':'dgate',
				'pname':'f_wmsa_shouhuo',
				'i':this.FNULLE([
				'bill',this.editForm.bill,
				'opmode','YHSH_qryyjdbill',
				'kqid', this.ryuser.kqid])
				}, '查带卸货预检单',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
				if(ret_iserr){ //传入的true参数,理论上不会有此回调了
					_self.$toast.fail('查询失败')
					_self.$store.commit('hideLoading');
				}else{
					var rtn_json_obj = null;
					_self.$store.commit('hideLoading');
					if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
					}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
					}
					_self.yujianTable = rtn_json_obj
					console.log("得到数据")
					console.log(_self.yujianTable)
					if(_self.yujianTable.length >0){
						_self.selectBillsVisible = true
					}else{
						_self.$toast.fail('暂无收货单请核对收货单号')
						_self.isdisabled = false
					}
				}
			});
		},
		 saveZhengDanBtn(){
			 // 原型阶段用到的字段,及字段的demo值!!!
			 var _self = this;
			 var ldemodata = [{retval:0, errmsg:'返回数据集'},]
			 this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_shouhuo',
					'i':this.FNULLE([
					'bill',this.editForm.bill,
					'opmode','YHSH_zdqr_q',
					])
			 	}, '查整单结单',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
			 	if(ret_iserr){ //传入的true参数,理论上不会有此回调了
			 		_self.$toast.fail('查询失败')
			 		_self.$store.commit('hideLoading');
			 	}else{
			 		var rtn_json_obj = null;
			 		_self.$store.commit('hideLoading');
			 		if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
			 		}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
			 		}

					let zhengdanData = rtn_json_obj[0]
					console.log(rtn_json_obj[0])

					_self.$dialog.confirm({
					  title: '提示',
					  message:'请确认收货单'+_self.editForm.bill+'总应收:'+zhengdanData.yings+'已收:'+zhengdanData.yis+'标签数:'+zhengdanData.num_bq+'托盘数:'+zhengdanData.num_tp,
					}).then(() => {
						_self.saveZhengdan()
					    // on confirm
					}).catch(() => {
							// on cancel
					});
			 	}
			 });
		 },
		 saveZhengdan(){
				var _self = this;
				var ldemodata = [{retval:0, errmsg:'返回数据集'},]
				this.MYPOST({
					'method':'dgate',
					'pname':'f_wmsa_shouhuo',
					'i':this.FNULLE([
					'opmode','YHSH_zdqr',
					'bill',this.editForm.bill,
					])
					}, '收货列表',true, ldemodata, function(ret_obj, ret_iserr,ret_errmess,ret_oldresp){
					if(ret_iserr){ //传入的true参数,理论上不会有此回调了
						_self.$toast.fail('查询失败')
						_self.$store.commit('hideLoading');
					}else{
						var rtn_json_obj = null;
						_self.$store.commit('hideLoading');
						if(ret_obj != null){ rtn_json_obj = ret_obj; //返回的接口可以直接解析的情况
						}else{  rtn_json_obj = _self.arr2Obj(ret_oldresp.data); //非标准的dgate接口,返回的一个不兼容的处理
						}
						if(rtn_json_obj[0].ret_ret == '-1'){
							_self.$toast(rtn_json_obj[0].ret_mess)
						}else{
							_self.$toast(rtn_json_obj[0].ret_mess)
							// _self.editForm = {
							// 		bill:'',
							// 		subsname:'',
							// 		itemid:'',
							// 		posin:'',
							// 		storeid:'', //门店ID
							// 		venname:'',  //供应商名称
							// 		vendor:'',   //供应商
							// 		subsname:'', //商品名称
							// 		totqty:'',  //应收数量
							// 		ystotqty:'', //已收数量
							// 		unit:'',  //箱装
							// 		kcuom:'', //单位
							// 		pack:'',  //箱数
							// 		qty:'',
							// 		shserno_s:'',
							// }
								_self.danjuhuizong = {
									num_bq:'',
									num_tp:'',
									yings:'',
									yis:'',
									pznum:'',
									mx1:'',
									mx2:'',
								}
						}
					}
				});
		 },
  },
  components:{

  },
  computed: {
     ryuser: function(){
       return this.GWO(true).gUSER;
     }
  },
  mounted :function(){
    var _self = this; window.GWO().debug=this;
		// console.log(window._gwo_.gUSER.operatorid)
		// this.czyid  = window._gwo_.gUSER.operatorid
  }
}

</script>
<style scoped lang="scss">
// 引入公共样式
@import '@/assets/css/base.scss';
@import '@/assets/css/input.scss';
.ywshouhuo_xhr{
	padding-top:50px;
	padding-bottom: 50px;
}


.skuInputdate{
	width:60%;
	max-width: 480px;
	height:45px;
	line-height: 45px;
	background: #FFFFFF;
	border-radius: 20px;
	border: 1px solid #63A8F8;
	box-sizing: border-box;
	box-sizing: border-box;
	padding-left: 10px;
	padding-right: 10px;
	font-size: 20px;
	font-weight: bold;
}

.goodsNameWarp{
	font-size: 20px;
	display: flex;
	margin-bottom: 10px;
	font-weight: bold;
	display: flex;
	flex: 1;
	span{
		display: block;
	}
	.label{
		width:100px;
	}
	.value{
		line-height: 22px;
		width: calc(100% - 100px);
	}
}

div.rowInput{
	display: flex;
	margin-bottom: 10px;
	div.rowInput_left{
		width: 50%;
		display: flex;
		align-items: center;
		box-sizing: border-box;
		padding-right: 5px;
	}
	div.rowInput_right{
		width: 50%;
		display: flex;
		align-items: center;
	}
	div.rowInputLabel{
		font-weight: bold;
		font-size: 20px;
		width: 110px;
	}


}

div.tishiMessage{
	font-size: 20px;
	font-weight: bold;
	margin-bottom: 10px;
	line-height: 25px;
}



/deep/.input_tow{
			background: #FFFFFF;
			border-radius: 20px;
			border: 1px solid #63A8F8;
			box-sizing: border-box;
			width:100px;
			height:45px;
      box-sizing: border-box;
      padding-left:15px;
      padding-right: 10px;
      font-size: 20px;
      font-weight: bold;
}





.errorMessage{
  color: red;
  font-size:18px;
  font-weight: bold;
}

.danjuRow {
  p {
    span {
      display: inline-block;
      min-width: 80px;
    }
  }
}
</style>

